package main

import (
	"fmt"
	"net"
	"net/rpc/jsonrpc"

	rpcdemo "gitee.com/jnshao/go-start/rpc"
)

func main() {
	conn, err := net.Dial("tcp", ":8080")
	if err != nil {
		panic(err)
	}
	defer conn.Close()
	client := jsonrpc.NewClient(conn)
	defer client.Close()

	var result float64
	//struct.method，调用方法为值接收者
	err = client.Call("DemoService.Div", rpcdemo.Arg{A: 10, B: 5}, &result)

	fmt.Println(result, err)

	//result := new(float64)
	////struct.method，调用方法为值接收者
	//err = client.Call("DemoService.Div", rpcdemo.Arg{A: 10, B: 5}, result)
	//
	//fmt.Println(*result, err)

	//jsonrpc数据格式：
	//{"method":"xxx","params":[],"id":0}

}
